package com.fc.authentication.modules.order.rs;

import com.fc.authentication.common.dto.Result;
import com.fc.authentication.modules.order.domain.Order;
import com.fc.authentication.modules.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Sunny on 2018/6/30.
 */

@RestController
@RequestMapping("/api/order")
public class OrderResource {

    @Autowired
    private OrderService orderService;


    @GetMapping("/list")
    public Result list(@PageableDefault(sort = {"orderNumber"}, direction = Sort.Direction.DESC) Pageable pageable)
    {
        Page<Order> orderPage = orderService.findAllOrders(pageable);
        return Result.ok(orderPage);
    }
}
